from django.shortcuts import render

# Create your views here.
from rest_framework import serializers
from rest_framework.generics import ListAPIView, RetrieveAPIView
from rest_framework.pagination import PageNumberPagination

from activities.models import Activities
from activities.serializer import  ActivitiesListSerializer, ActivitiesDetailSerializer


class StandardPageNumberPagination(PageNumberPagination):
    page_size = 12
    page_size_query_param = 'page_size'
    max_page_size = 1000


class ActivitiesListView(ListAPIView):
    """商品列表视图"""

    serializer_class = ActivitiesListSerializer
    queryset = Activities.objects.filter(is_delete=False).order_by('-start_time')
    pagination_class = StandardPageNumberPagination

    # 查询数据、排序

    #分页

    #序列返回

class ActivitiesDetailView(RetrieveAPIView):
    """
    活动详情
    """
    serializer_class = ActivitiesDetailSerializer
    queryset = Activities.objects.all()